<!DOCTYPE html>
<html style="background-color: #F1F4FB">

<head>
    <meta charset="utf-8">
    <title>科研项目台账页面</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<style>
    .Right {
        overflow-y: auto;
        width: 100%;
        left: 16%;
        top: 144px;
    }
    .layui-table-cell {
        text-align: center;
        font-size:14px;
        padding:0 5px;
        height:auto;
        overflow:visible;
        text-overflow:inherit;
        white-space:normal;
        word-break: break-all;
    }
    .layui-laypage-limits select {
        width: 70px;
    }
</style>

<body>
<!--头部-->

<!--容器-->
<div class="layui-container" style="background-color: #ffffff;width:96%;margin-top:60px;padding:16px;border-radius: 10px">

<#--    <div class="layui-row">-->
<#--        <div class="layui-col-md3 layui-col-md-offset9">-->
<#--            <input class="layui-btn layui-btn-normal layui-btn-sm fr ml10" type="button" value="导出Excel" onclick="exportTable()">-->
<#--            <input class="layui-btn layui-btn-danger layui-btn-sm fr" type="button" value="预览Excel" onclick="viewTable()">-->
<#--        </div>-->
<#--    </div>-->
    <div class="layui-row">
        <table id="booktable" layui-filter="booktable">

        </table>
    </div>

    <#--	<div class="Right fr mt10">-->
    <#--		<div class="layui-row" style="background-color: #e0e0e0;padding:20px 1%;margin-top:30px;border-radius: 5px">-->
    <#--			<div class="layui-col-md2">-->
    <#--				<span>计划类别:</span>-->

    <#--			</div>-->
    <#--			<div class="layui-col-md2" style="width: 26%">-->
    <#--				<span style="display: inline-block;width:27%">获取时间:</span>-->
    <#--				<input id="hp_time_begin" type="text"  style="display: inline-block;width:35%" value="2021-05-01">-->
    <#--				<span>至</span>-->
    <#--				<input id="hp_time_end" type="text"  style="display: inline-block;width:35%"  value="2021-05-02">-->
    <#--			</div>-->
    <#--		</div>-->
    <#--	</div>-->
</div>
<div style="height: 50px"></div>
<#--	<!--右侧内容&ndash;&gt;-->
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
<script type="text/html" id="sqtdcy">
    <div>
        <p>{{d.formDataList[0].data1}}</p>
        <p class="cursor" style="color: dodgerblue" onclick='seeAllMembers(&apos;{{d.spfF1}}&apos;,&apos;{{JSON.stringify(d.formDataList)}}&apos;)'>查看全部成员</p>
    </div>
</script>
<script type="text/html" id="sstdcy">
    <div>
        <p>{{d.formDataList2[0].data1}}</p>
        <p class="cursor" style="color: dodgerblue" onclick='seeAllMembers(&apos;{{d.spfF1}}&apos;,&apos;{{JSON.stringify(d.formDataList2)}}&apos;)'>查看全部成员</p>
    </div>
</script>
<#--<script type="text/html" id="xmjb">-->
<#--	{{# if(d.flag){ }}-->
<#--	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="update"><i class="layui-icon">&#xe640;</i>编辑</a>-->
<#--	{{# }else{ }}-->
<#--	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="handle"><i class="layui-icon">&#xe640;</i>办理</a>-->
<#--	{{# } }}-->
<#--</script>-->
<script type="text/javascript">
    var table,tableIns,laydate,form,layer;
    layui.use(['laydate','table','form','layer'], function () {
        laydate = layui.laydate;
        table = layui.table;
        form = layui.form;
        layer = layui.layer;
        //执行一个laydate实例
        // laydate.render({
        //     elem: '#hp_date_start' //获批时间开思
        // });
        // laydate.render({
        //     elem: '#hp_date_end' //获批时间结束
        // });
        var jsonObjStr = localStorage.getItem("count-detail-filter");
        var jsonObj = JSON.parse(jsonObjStr);
        //方法级渲染
        tableIns = table.render({
            id: 'booktable',
            elem: '#booktable',
            url: '/search/decision/form/book/110007',
            height: "full",
            page: true,
            where: jsonObj,
            cols: [[
                {
                    title: '序号', width: '8%', templet: function (res) {
                        return res.LAY_INDEX;
                    }
                },
                {field: 'spfF4', title: '获批时间', width: '10%'},
                {field: 'spfF2', title: '项目级别', width: '10%',templet: function (d) {
                        return '<span>'+getXmjb(d.spfF2)+'</span>';
                    }},
                {field: 'spfF3', title: '计划类别', width: '10%',templet: function (d) {
                        return '<span>'+getJhlb(d.spfF3)+'</span>'
                    }
                },
                {field: 'spfF1', title: '项目名称', width: '20%'},
                {field: 'spfF5', title: '项目编号', width: '20%'},
                {field: 'spfF6', title: '资金(经费)金额(元)', width: '12%'},
                {field: 'spfF7', title: '计划批准下达单位', width: '15%'},
                {field: 'spfF8', title: '批准文号', width: '15%'},
                {field: 'spfF9', title: '项目起止年月', width: '20%',templet: function (d) {
                        return '<span>'+d.spfF9+'</span>&nbsp;<span>至</span>&nbsp;<span>'+d.spfF10+'</span>';
                    }
                },
                {field: 'spfF11', title: '项目进度', width: '10%',templet: function (d) {
                        return '<span>'+getxmjd(d.spfF11)+'</span>'
                    }},
                {field: 'spfF12', title: '项目负责人', width: '10%'},
                {field: 'spfF13', title: '申请项目团队总人数', width: '10%'},
                {field: 'formDataList', title: '申请项目团队成员', width: '10%',templet: '#sqtdcy'},
                {field: 'spfF14', title: '项目实施团队总人数', width: '10%'},
                {field: 'formDataList2', title: '项目实施团队成员', width: '10%',templet: '#sstdcy'},
                {field: 'fileList1', title: '项目申请书', width: '15%',templet: function(d){
                        var returnStr = '';
                        if(d.fileList1 && d.fileList1.length > 0){
                            for(var a=0;a<d.fileList1.length;a++){
                                returnStr = returnStr + '<p>'+d.fileList1[a].fileName+'</p>';
                            }
                            return returnStr;
                        }else{
                            return '';
                        }
                    }},
                {field: 'fileList2', title: '项目协议书或盖章扫描件', width: '15%',templet: function(d){
                        var returnStr = '';
                        if(d.fileList2 && d.fileList2.length > 0){
                            for(var a=0;a<d.fileList2.length;a++){
                                returnStr = returnStr + '<p>'+d.fileList2[a].fileName+'</p>';
                            }
                            return returnStr;
                        }else{
                            return '';
                        }
                    }},
                {field: 'fileList3', title: '项目官方立项通知', width: '15%',templet: function(d){
                        var returnStr = '';
                        if(d.fileList3 && d.fileList3.length > 0){
                            for(var a=0;a<d.fileList3.length;a++){
                                returnStr = returnStr + '<p>'+d.fileList3[a].fileName+'</p>';
                            }
                            return returnStr;
                        }else{
                            return '';
                        }
                    }},
                {field: 'fileList4', title: '项目任务书或盖章扫描件', width: '15%',templet: function(d){
                        var returnStr = '';
                        if(d.fileList4 && d.fileList4.length > 0){
                            for(var a=0;a<d.fileList4.length;a++){
                                returnStr = returnStr + '<p>'+d.fileList4[a].fileName+'</p>';
                            }
                            return returnStr;
                        }else{
                            return '';
                        }
                    }},
                {field: 'fileList5', title: '项目内部立项文件', width: '15%',templet: function(d){
                        var returnStr = '';
                        if(d.fileList5 && d.fileList5.length > 0){
                            for(var a=0;a<d.fileList5.length;a++){
                                returnStr = returnStr + '<p>'+d.fileList5[a].fileName+'</p>';
                            }
                            return returnStr;
                        }else{
                            return '';
                        }
                    }},
                {field: 'fileList6', title: '中期检查文件', width: '15%',templet: function(d){
                        var returnStr = '';
                        if(d.fileList6 && d.fileList6.length > 0){
                            for(var a=0;a<d.fileList6.length;a++){
                                returnStr = returnStr + '<p>'+d.fileList6[a].fileName+'</p>';
                            }
                            return returnStr;
                        }else{
                            return '';
                        }
                    }},
                {field: 'fileList7', title: '结项验收文件', width: '15%',templet: function(d){
                        var returnStr = '';
                        if(d.fileList7 && d.fileList7.length > 0){
                            for(var a=0;a<d.fileList7.length;a++){
                                returnStr = returnStr + '<p>'+d.fileList7[a].fileName+'</p>';
                            }
                            return returnStr;
                        }else{
                            return '';
                        }
                    }},
                {field: 'fileList8', title: '其他', width: '15%',templet: function(d){
                        var returnStr = '';
                        if(d.fileList8 && d.fileList8.length > 0){
                            for(var a=0;a<d.fileList8.length;a++){
                                returnStr = returnStr + '<p>'+d.fileList8[a].fileName+'</p>';
                            }
                            return returnStr;
                        }else{
                            return '';
                        }
                    }},
                {field: 'spfF15', title: '备注', width: '15%'}
            ]],
            done: function (res, currentCount) {

            }
        });
    });



    // function query() {
    //     //计划类别
    //     var jhlb = $('#play_type_select').val();
    //
    //     //获批时间:
    //     var hpshStart = $('#hp_date_start').val();
    //     var hpshEnd = $('#hp_date_end').val();
    //
    //     //项目名称
    //     var projectName = $('#project_name').val();
    //
    //     //项目级别
    //     var xmjb = $('#project_level_select').val();
    //
    //     //项目负责人
    //     var xmfzr = $('#project_fzr').val();
    //
    //     //计划(批准)下达单位
    //     var xdunit = $('#project_allow_unit').val();
    //
    //     var jsondata = {
    //         spfF3:jhlb,
    //         spfF9:hpshStart,
    //         spfF10:hpshEnd,
    //         spfF1:projectName,
    //         spfF2: xmjb,
    //         spfF12:xmfzr,
    //         spfF7:xdunit
    //     };
    //     table.reload('booktable', {where: jsondata});
    // }

    // function resetQuery(){
    //     $('#play_type_select').val('000');
    //     $('#hp_date_start').val('');
    //     $('#hp_date_end').val('');
    //     $('#project_name').val('');
    //     $('#project_level_select').val('000');
    //     $('#project_fzr').val('');
    //     $('#project_allow_unit').val('');
    //     query();
    // }



    function seeAllMembers(formProjectName,data){
        var names = [];
        var fieldName = '';
        var dataObj = JSON.parse(data);
        if(dataObj && dataObj.length>0){
            for(var a=0;a<dataObj.length;a++){
                if(dataObj[a].data1){
                    if(a == 0){
                        if(dataObj[a].data10 && 'shishimems' == dataObj[a].data10){
                            fieldName = '项目实施团队成员';
                        }else if(dataObj[a].data10 && 'shenbaomems' == dataObj[a].data10){
                            fieldName = '申请项目团队成员';
                        }
                    }
                    var aStData = {};
                    aStData.index = a+1;
                    aStData.name = dataObj[a].data1;
                    names[names.length] = aStData;
                }
            }
            // for(var b=0;b<20;b++){
            // 	var testData = {};
            // 	testData.index = names.length+1;
            // 	testData.name = '测试';
            // 	names[names.length] = testData;
            // }
            localStorage.setItem("form-project-name",formProjectName);
            localStorage.setItem("form-project-members",JSON.stringify(names));
            localStorage.setItem("form-project-field-name",fieldName);
            var w = ($(window).width()*0.5);
            var h = ($(window).height()*0.8);
            layer.open({
                type: 2,
                title: false,
                closeBtn: 1,
                shade: 0.8,
                area: [w+'px',h+'px'],
                content: '/search/decision/showMembers',
                success: function(layero, index){

                },
                end: function () {
                    localStorage.removeItem("form-project-name");
                    localStorage.removeItem("form-project-members");
                    localStorage.removeItem("form-project-field-name");
                }
            })
        }
    }

    function getXmjb(xmjb){
        var xmjbListStr = '${xmjbListStr}';
        var xmjbList = JSON.parse(xmjbListStr);
        var returnStr = '';
        if(xmjbList && xmjbList.length>0){
            for(var a=0;a<xmjbList.length;a++){
                if(xmjb == xmjbList[a].badtCode){
                    returnStr = xmjbList[a].badtName;
                }
            }
        }
        return returnStr;
    }

    function getxmjd(xmjd){
        var xmjdListStr = '${xmjdListStr}';
        var xmjdList = JSON.parse(xmjdListStr);
        var returnStr = '';
        if(xmjdList && xmjdList.length>0){
            for(var a=0;a<xmjdList.length;a++){
                if(xmjd == xmjdList[a].badtCode){
                    returnStr = xmjdList[a].badtName;
                }
            }
        }
        return returnStr;
    }

    function getJhlb(jhlb){
        var jhlbListStr = '${jhlbListStr}';
        var jhlbList = JSON.parse(jhlbListStr);
        var returnStr = '';
        if(jhlbList && jhlbList.length>0){
            for(var a=0;a<jhlbList.length;a++){
                if(jhlb == jhlbList[a].badtCode){
                    returnStr = jhlbList[a].badtName;
                }
            }
        }
        return returnStr;
    }

    function viewTable(){
        var jhlb = $('#play_type_select').val();
        var hpshStart = $('#hp_date_start').val();
        var hpshEnd = $('#hp_date_end').val();
        var projectName = $('#project_name').val();
        var xmjb = $('#project_level_select').val();
        var xmfzr = $('#project_fzr').val();
        var xdunit = $('#project_allow_unit').val();
        var jsondata = {
            spfF3:jhlb,
            spfF9:hpshStart,
            spfF10:hpshEnd,
            spfF1:projectName,
            spfF2: xmjb,
            spfF12:xmfzr,
            spfF7:xdunit
        };
        layerAjaxGet('/search/decision/form/book/viewTable/110007',jsondata,'',function (res) {
            if(res.flag){
                if(res.data){
                    var w = ($(window).width()*0.8);
                    var h = ($(window).height()*0.8);
                    POBrowser.openWindowModeless('/sys/office/openwordTemp?ft=1&fid=' + res.data, 'width=1200px;height=800px;', '{}')
                    // var w = ($(window).width()*0.8);
                    // var h = ($(window).height()*0.8);
                    // layer.open({
                    // 	type: 1,
                    // 	title: false,
                    // 	closeBtn: 1,
                    // 	shade: 0.8,
                    // 	area: [w+'px',h+'px'],
                    // 	content: res.data,
                    // 	success: function(layero, index){
                    //
                    // 	},
                    // 	end: function () {
                    //
                    // 	}
                    // })
                }
            }
        })
    }

    function exportTable(){
        var jhlb = $('#play_type_select').val();
        var hpshStart = $('#hp_date_start').val();
        var hpshEnd = $('#hp_date_end').val();
        var projectName = $('#project_name').val();
        var xmjb = $('#project_level_select').val();
        var xmfzr = $('#project_fzr').val();
        var xdunit = $('#project_allow_unit').val();
        var para = '';
        if(jhlb){
            para = para+'&spfF3='+jhlb;
        }
        if(hpshStart){
            para = para+'&spfF9='+hpshStart;
        }
        if(hpshEnd){
            para = para+'&spfF10='+hpshEnd;
        }
        if(projectName){
            para = para+'&spfF1='+projectName;
        }
        if(xmjb){
            para = para+'&spfF2='+xmjb;
        }
        if(xmfzr){
            para = para+'&spfF12='+xmfzr;
        }
        if(xdunit){
            para = para+'&spfF7='+xdunit;
        }
        //获取全部数据:
        var url= '/search/decision/form/export/book/110007?a_='+Math.random()+para;
        location.href = url;
    }

</script>
</body>

</html>